﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing;

[DefaultProperty("MessageTemplate"), ToolboxData("<{0}:Controls_TemplatControl runat=server></{0}:Controls_TemplatControl>")]
public partial class Controls_TemplatControl : System.Web.UI.UserControl
{

		public string ImgTopLeft { get; set; }
		public string ImgTopRight { get; set; }
		public string ImgBottomLeft { get; set; }
		public string ImgBottomRight { get; set; }
		public string ImgSfondo { get; set; }
		public string Titolo { get; set; }

		public string PathDirImages { get; set; }

		//protected readonly string mBaseUrl ="Http://"+ HttpContext.Current.Request.Url.Host;

		private ITemplate messageTemplate = null;

		void Page_Init()
		{ 
		  if (messageTemplate != null)
				{
								MessageContainer container = new MessageContainer(0,"");
								messageTemplate.InstantiateIn(container);
								PlaceHolder1.Controls.Add(container);
						
				}
		}//fM

		protected void Page_Load(object sender, EventArgs e)
		{

		}


		[TemplateContainer(typeof(MessageContainer)), Browsable(true)]
		[PersistenceMode(PersistenceMode.InnerProperty)]
		public ITemplate MessageTemplate
		{
				get
				{
						return messageTemplate;
				}
				set
				{
						messageTemplate = value;
				}
		}

}//fC

public class MessageContainer : Control, INamingContainer
{
		private int m_index;
		private String m_message;
		internal MessageContainer(int index, String message)
		{
				m_index = index;
				m_message = message;
		}
		public int Index
		{
				get
				{
						return m_index;
				}
		}
		public String Message
		{
				get
				{
						return m_message;
				}
		}
}